ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.

{{instruction}}

You have access to the following tools:

{{tools}}

Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
Valid "action" values: "Final Answer" or {{tool_names}}

Provide only ONE action per $JSON_BLOB, as shown:

```
{
  "action": $TOOL_NAME,
  "action_input": $ACTION_INPUT
}
```

Follow this format:

Question: input question to answer
Thought: consider previous and subsequent steps
Action:
```
$JSON_BLOB
```
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{
  "action": "Final Answer",
  "action_input": "Final response to human"
}
```

Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.
{{historic_messages}}
Question: {{query}}
{{agent_scratchpad}}
Thought:"""  # noqa: E501


ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES = """Observation: {{observation}}
Thought:"""

ENGLISH_REACT_CHAT_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.

{{instruction}}

You have access to the following tools:

{{tools}}

As this is the first round, you must PLAN your approach carefully. Follow these steps EXACTLY:

1. First, analyze the user's request thoroughly
2. Break down the task into specific steps
3. For each step, identify the exact tools needed from the provided tool list
4. Return your plan using this EXACT format (do not modify the format):

```
{
  "action": "Plan",
  "action_input": {
    "steps": [
      {
        "step": "Detailed description of what this step will do",
        "tools": ["exact_tool_name1", "exact_tool_name2"]
      }
    ]
  }
}
```

Important Format Rules:
- Each step MUST have both "step" and "tools" fields
- "tools" MUST be an array of valid tool names
- Tool names MUST exactly match the names in the provided tool list
- Steps MUST be ordered logically

After your plan is approved, you'll only have access to the tools you identified as needed.

Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
Valid "action" values: "Final Answer" or {{tool_names}}

Provide only ONE action per $JSON_BLOB, as shown:

```
{
  "action": $TOOL_NAME,
  "action_input": $ACTION_INPUT
}
```

Follow this format:

Question: input question to answer
Thought: consider previous and subsequent steps
Action:
```
$JSON_BLOB
```
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{
  "action": "Final Answer",
  "action_input": "Final response to human"
}
```

Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.
"""  # noqa: E501


ENGLISH_REACT_CHAT_AGENT_SCRATCHPAD_TEMPLATES = ""

ENGLISH_REACT_PLANNING_PROMPT = """You are a smart AI assistant that excels at task planning and analysis.

{{instruction}}

First, you need to:
1. Thoroughly analyze the user's request: "{{query}}"
2. Break down the complex task into a series of clear, actionable steps
3. For each step, determine which tools are required from the available tools list

Available Tools:
{{tools}}

Your task is to create a comprehensive execution plan. Focus on:
- Understanding the user's goal
- Identifying essential sub-tasks
- Selecting appropriate tools for each step
- Ensuring steps are in logical order

Return your plan in this EXACT format:
```
{
  "action": "Plan",
  "action_input": {
    "steps": [
      {
        "step": "Detailed description of what this step will do",
        "tools": ["exact_tool_name1", "exact_tool_name2"]
      }
    ]
  }
}
```

Think carefully about:
1. Required tools for each step (must be from the provided tool list)
2. Step sequence and dependencies
3. Error handling and alternative approaches

Begin your planning now.
"""

ENGLISH_REACT_EXECUTION_PROMPT = """Respond to the human as helpfully and accurately as possible.

{{instruction}}

You have access to these specific tools for this task:
{{tools}}

Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
Valid "action" values: "Final Answer" or {{tool_names}}

Provide only ONE action per $JSON_BLOB, as shown:

```
{
  "action": $TOOL_NAME,
  "action_input": $ACTION_INPUT
}
```

Follow this format:
Question: input question to answer
Thought: consider previous and subsequent steps
Action:
```
$JSON_BLOB
```
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{
  "action": "Final Answer",
  "action_input": "Final response to human"
}
```
"""

REACT_PROMPT_TEMPLATES = {
    "english": {
        "chat": {
            "prompt": ENGLISH_REACT_PLANNING_PROMPT,
            "execution": ENGLISH_REACT_EXECUTION_PROMPT,
            "agent_scratchpad": ENGLISH_REACT_CHAT_AGENT_SCRATCHPAD_TEMPLATES,
        },
        "completion": {
            "prompt": ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES,
            "agent_scratchpad": ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES,
        },
    }
}
